home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / tutorial / adatu311.zip / DAT2TXT.ADA < prev    next >
Text File  |  1996-01-10  |  2KB  |  52 lines

  1. -- DAT2TXT.ADA   Ver. 3.11   10-JAN-1996   Copyright 1988-1996 John J. Herro
  2. --
  3. -- SOFTWARE INNOVATIONS TECHNOLOGY          http://members.aol.com/AdaTutor
  4. -- 1083 MANDARIN DR NE                      ftp://members.aol.com/AdaTutor
  5. -- PALM BAY FL 32905-4706
  6. --                                          johnherro@aol.com
  7. -- (407) 951-0233                           john.herro%374-38-2@satlink.oau.org
  8. --
  9. -- Run this program on a PC before installing ADA-TUTR on another computer.
  10. -- It translates ADA_TUTR.DAT to TUTOR.TXT, a text file that can be easily
  11. -- transferred to other computers.  Then compile and run TXT2DAT.ADA on the
  12. -- other machine to create ADA_TUTR.DAT from TUTOR.TXT.
  13. --
  14. with Direct_IO, Text_IO;
  15. procedure DAT2TXT is
  16.    subtype Block_Subtype is String(1 .. 64);
  17.    package Random_IO is new Direct_IO(Block_Subtype);
  18.    Data_File  : Random_IO.File_Type;                         -- The input file.
  19.    Text_File  : Text_IO.File_Type;                          -- The output file.
  20.    Block      : Block_Subtype;             -- A block of 64 bytes being copied.
  21.    OK         : Boolean := True;     -- True when both files open successfully.
  22.    Legal_Note : constant String := " Copyright 1988-96 John J. Herro ";
  23.                        -- Legal_Note isn't used by the program, but it causes
  24.                        -- most compilers to place this string in the .EXE file.
  25. begin
  26.    begin
  27.       Random_IO.Open(Data_File, Random_IO.In_File, Name => "ADA_TUTR.DAT");
  28.    exception
  29.       when Random_IO.Name_Error =>
  30.          Text_IO.Put_Line(
  31.               "I'm sorry.  The file ADA_TUTR.DAT seems to be missing.");
  32.          OK := False;
  33.    end;
  34.    begin
  35.       Text_IO.Create(Text_File, Name => "TUTOR.TXT");
  36.    exception
  37.       when others =>
  38.          Text_IO.Put_Line("I'm sorry.  I can't seem to create TUTOR.TXT.");
  39.          Text_IO.Put_Line("Perhaps that file already exists?");
  40.          OK := False;
  41.    end;
  42.    if OK then
  43.       while not Random_IO.End_Of_File(Data_File) loop
  44.          Random_IO.Read(Data_File, Item => Block);
  45.          Text_IO.Put_Line(File => Text_File, Item => Block);
  46.       end loop;
  47.       Random_IO.Close(Data_File);
  48.       Text_IO.Close(Text_File);
  49.       Text_IO.Put_Line("TUTOR.TXT created.");
  50.    end if;
  51. end DAT2TXT;
  52.